package io.chenglicun.modules.clc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.chenglicun.common.service.impl.CrudServiceImpl;
import io.chenglicun.common.constant.Constant;
import io.chenglicun.common.utils.ConvertUtils;
import io.chenglicun.modules.clc.dao.ClcExamResultAnswerDao;
import io.chenglicun.modules.clc.dto.ClcExamResultAnswerDTO;
import io.chenglicun.modules.clc.entity.ClcExamResultAnswerEntity;
import io.chenglicun.modules.clc.service.ClcExamResultAnswerService;
import io.chenglicun.modules.security.user.SecurityUser;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

/**
 * 考试结果所选答案
 *
 * @author HB 137664951@qq.com
 * @since 1.0 2023-10-18
 */
@Service
public class ClcExamResultAnswerServiceImpl extends CrudServiceImpl<ClcExamResultAnswerDao, ClcExamResultAnswerEntity, ClcExamResultAnswerDTO> implements ClcExamResultAnswerService {

    @Override
    public QueryWrapper<ClcExamResultAnswerEntity> getWrapper(Map<String, Object> params){
        QueryWrapper<ClcExamResultAnswerEntity> wrapper = new QueryWrapper<>();


        return wrapper;
    }

    @Override
    public List<ClcExamResultAnswerDTO> getListByExamResultId(Long ...examResultIds) {
        List<ClcExamResultAnswerEntity> entities = baseDao.selectList(
                new QueryWrapper<ClcExamResultAnswerEntity>()
                        .lambda().in(ClcExamResultAnswerEntity::getExamResultId, Arrays.asList(examResultIds))
        );

        return ConvertUtils.sourceToTarget(entities, ClcExamResultAnswerDTO.class);
    }

    @Override
    @Transactional
    public void saveBatch(List<ClcExamResultAnswerDTO> dtos) {
        List<ClcExamResultAnswerEntity> entities = ConvertUtils.sourceToTarget(dtos, ClcExamResultAnswerEntity.class);
        this.insertBatch(entities);
    }
}